<?php

require '../model-db-connection/config.php';

$order_id = $_GET['order_id'];
$project_id = $_GET['project_id'];
$team_code = $_GET['team_code'];
$assign_date = $_GET['assign_date'];
$target_date = $_GET['target_date'];
$remark = $_GET['remark'];
$project_order_remark = $_GET['project_order_remark'];
$project_order_status = $_GET['project_order_status'];


$assignID = md5(date('l jS \of F Y h:i:s A') . "_" . $project_code);

$sqlInsertIntoProjectOrderTbl = "INSERT INTO QRC_ASSIGN_ORDER (ASSIGN_ID,WO_ID,PROJECT_ID,TEAM_CODE,ASSIGN_DATE,TARGET_DATE,REMARK)"
        . " VALUES "
        . "('$assignID','$order_id','$project_id','$team_code',NOW(),'$target_date','$remark');";

$resultSet = mysql_query($sqlInsertIntoProjectOrderTbl);

$sqlUpdateProjectOrder = "UPDATE QRC_PROJECT_ORDER"
        . " SET assign_id = '$assignID',project_status = 'Assign', remark = '$project_order_remark'"
        . " WHERE project_order_id LIKE '$order_id';";
mysql_query($sqlUpdateProjectOrder);

if ($resultSet) {  
    echo '1';
} else {
    echo '0';
}